package net.chrisrichardson.ec2deployer.core

import net.chrisrichardson.ec2deployer.testutil.AWSPropertiesUtil;

class EC2IntegrationTest extends GroovyTestCase {

    EC2 ec2

    void setUp() {
        AWSProperties awsProperties = AWSPropertiesUtil.makeAWSProperties()
        ec2 = new EC2(awsProperties)
    }

    public void testNewServer() {
        EC2Server server = ec2.newServers(1)[0]
        assertNotNull server.availabilityZone
        server.stop()
    }

    public void testNewServerElsewhere() {
        EC2Server server = ec2.newServers(1)[0]
        EC2Server server2 = ec2.newServersElsewhere(1, EC2InstanceType.SMALL, server)[0]
        assertTrue server.availabilityZone != server2.availabilityZone
        server.stop()
        server2.stop()
    }

    public void testNewServerAndAssociateAddress() {
        EC2Server server = ec2.newServers(1)[0]
        assert server.associateAddress("75.101.146.44")
        server.stop()
    }

}